import { http } from '@/utils/http'

// 百度绘画ai 获取认证token
export const baiduAuth = (params?: any) => {
  return http.get<{}, HttpResponse>('/home/api/experience/aigc/auth', { params })
}

/**
 *
 * @param params 绘画接口
 * {
   "prompt": "睡莲",
   "width": 1024,
   "height": 1024,
   "image_num": 1,
   "image": ""（base64 编码）, // 参考图
   "change_degree":1
}
 * @returns
 */
export const txtToImg = (data?: any) => {
  return http.post<{}, HttpResponse<string>>('/home/api/experience/aigc/txtToImg', { data })
}

/**
 *
 * @param params 保存图片
 * {imgBoList:[{
 * imgUrl:[],
 * reqParams: string 绘画参数
 * taskId：string 任务id
 * }]}
 * @returns
 */
export const saveImg = (data?: any) => {
  return http.request<any>('post', '/home/api/experience/aigc/save', { data })
}

/**
 *  根据taskid 查询生成的图片信息
 * @param params
 * @returns
 */
export const getImg = (modelName: string, taskId: string) => {
  return http.get<{}, HttpResponse>(`/home/api/experience/aigc/getImg/${modelName}/${taskId}`)
}

/**
 * 获取我生成的图片列表
 * @param params
 * @returns
 */
export const getIcpImgList = () => {
  return http.request<any>('get', '/home/api/experience/aigc/getIcpImgList')
}

/**
 * 获取可用模型列表
 * @param params
 * @returns
 */
export const getModelList = () => {
  return http.get<{}, HttpResponse<Array<AigcModel>>>('/home/api/experience/aigc/allModels')
}

/**
 * 删除选中的图片
 * @param id
 * @returns
 */
export const delImg = (id: string) => {
  return http.request<any>('delete', `/home/api/experience/aigc/delImg/${id}`)
}

export type AigcModel = {
  name: string
  alias: string
}
